package com.gxa.weixing.pc.service.impl;

import com.gxa.weixing.core.pojo.City;
import com.gxa.weixing.core.service.impl.BaseServiceImpl;
import com.gxa.weixing.pc.mapper.CityMapper;
import com.gxa.weixing.pc.service.CityService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author ChenJ
 * @date 2022/01/10 10:19
 **/
@Service("cityService")
@Transactional(rollbackFor = Throwable.class)
public class CityServiceImpl extends BaseServiceImpl<City> implements CityService {

    @Resource
    private CityMapper cityMapper;

    /**
     * 获取城市列表
     *
     * @param id 父级编号pid
     * @return
     */
    @Override
    public List<City> getCity(Long id) {
        List<City> cityList = new ArrayList<>(16);
        if (id==null){
            cityList = cityMapper.getProvince();
        }else {
            cityList = cityMapper.getLowerCity(id);
        }
        return cityList;
    }
}
